﻿using MCP.BL.Messages;

namespace MCP.Model.Helpers
{
    /// <summary>
    /// Helper class for client messages constructing.
    /// </summary>
	public static class MessageHelper
	{
		/// <summary>
		/// Creates simple RegularMessage with text only.
		/// </summary>
		/// <param name="text">Message text.</param>
		/// <returns>Simple RegularMessage.</returns>
		public static SimpleMessage Create(string text)
		{
			return new SimpleMessage(text, MessagePriority.Medium, MessageType.Notification);
		}

        /////// <summary>
        /////// Composes message about current balance.
        /////// </summary>
        /////// <returns>CurrentBalanceMessage with detailed description or with request to fill Settings.</returns>
        /////// <remarks>DB request for monthly checks.</remarks>
        ////public static CurrentBalanceMessage CreateCurrentBalanceMessage()
        ////{
        ////    var message = new CurrentBalanceMessage();

        ////    if (CurrentUserHelper.User.MonthIncome.HasValue)
        ////    {
        ////        // DB connection:
        ////        double? currentBalance = null;
        ////        double? percent = null;
        ////        using (var unitOfWork = new UnitOfWork())
        ////        {
        ////            var getChecksResult = unitOfWork.CheckRepository.GetChecks();
        ////            if (getChecksResult.Success)
        ////            {
        ////                var monthSpends = (double)getChecksResult.Result
        ////                    .Where(c => c.Date.Month == DateTime.Now.Month)
        ////                    .Sum(c => c.TotalPrice);
        ////                currentBalance = CurrentUserHelper.User.MonthIncome - monthSpends - CurrentUserHelper.User.MinBalance;

        ////                percent = currentBalance/(CurrentUserHelper.User.MonthIncome - CurrentUserHelper.User.MinBalance)*100;

        ////                message.ComposeMessage(currentBalance, percent);
        ////            }
        ////            else
        ////            {
        ////                // TODO: resolve this situation!
        ////            }

        ////        }
        ////    }

        ////    return message;
        ////}
	}
}